Process of changing the basic engine.

Okay, we will start with the Basic Engine and from tehre on edit it.

First we open the client and change the Constant "MSG_NEW_CONTACT" to "MSG_MOVE"
The number maystay the same (7).
Do the same on the server please.

Now on the Client we delete the following:

[Objects]
obj_pointer
obj_faker_pointer

[Scripts]
case_msg_new_contact

In the script "case_warp" (on the client) get rid of the following lines:

with(obj_pointer)
instance_destroy() //destroy the contact-pointer from the last room

with(obj_fake_pointer)
instance_destroy() //destroy other Players pointer

global._setcontact = false //Enable the Player to create new movement contacts after the room-change

Those arent needed any longer.

Also open the "case_msg_warp" script and delete the following:


if instance_exists(next) //Destroy the contact-pointer if there is one
with next
instance_destroy()

If you dont delete all this you'll run into a few errors later :P


On the Server we also open the "obj_player" and in its Create Event we get rid of the following
lines of code:

//Define a few engine-variables
new_contact = false
new_contact_x = 0
new_contact_y = 0
old_contact_x = 1
old_contact_y = 1

We won't need those any longer.

On the server open the "case_msg_warp" script and get rid of the following lines:

new_contact = false //We delete the old contact point of the player


        if new_contact = true //If the Player is moving to a contact
        {
        clearbuffer()
        writebyte(MSG_NEW_CONTACT)
        writeshort(playerid)
        writeshort(new_contact_x)
        writeshort(new_contact_y)
        writeshort(x)
        writeshort(y)
        send_client(5,other.id)
        }


Okay, now that we got rid of those objects we'll move on.

So, open the obj_controller and get rid of the "Glob Left Pressed"-Event (Mouse left click)

In the "obj_other_player" we open the Create Event and then the script.
Get rid of "next = 0" we don't need it anylonger.

We'll keep the movement simple.
Just left, right, up and down should be enough to get how it works.

So, for the obj_player we make a "press <Right>" event
Now we add an exmpty script to the action field and fill in the following commands:

clearbuffer()
writebyte(MSG_MOVE)
writebyte(1)
send_server()
hspeed = 1

Okay, let me explain what the "writebyte(1)" does.

SO, as I told ya before we will use 4 directions we will walk to.

Right, Left, Up, Down

We will give each of those a number:

Right = 1
Left = 2
Up = 3
Down = 4

But we also have to think bout the fact that we stop pressing a key:

Stop Right = 5
Stop Left = 6
Stop Up = 7
Stop Down = 8

Yay, thats how our system will work.

Now go on and make a event like before for the other buttons (left, up and down)
Don't forget to use teh correct number there!
And of course change hspeed to vspeed when it comes to vertical movement :P


Okay, I'm done...what bout u? :P

Anyway, next we make a "release <Right>"-Event.

Again we put an exmpty script here and add teh following:

clearbuffer()
writebyte(MSG_MOVE)
writebyte(5)
send_server()
hspeed = 0

Pretty simple, eh?
Do the same for left, up and down...dont forget to use the correct values.
And change hspeed to vspeed when its needed <_<

Yay, we got it done :P

Eh, whats next...lets seeeee.... ._.,

Ah, right!
Let's switch to the server now =)

Okay, on the server open the "obj_player" and in its "User Defined 0"-Event open the script.
Get rid of the following:

case MSG_NEW_CONTACT: //Player made a new contact-point
case_msg_new_contact()
break;

Now add this:

case MSG_MOVE: //A Player moves
case_msg_move()
break;

Simple, huh?

Now the server can get information from the MSG_MOVE...but the script doesnt exist yet.
And, we also have to add a few movement values to the Player.

So, in "obj_player" create event we add the following variables:

_left = false
_right = false
_up = false
_down = false

Those variables will store if the Player walks into a direction.

Now we create the script "case_msg_move"

Inside we place the following:

_dir = readbyte()
switch(_dir)
{
case 1: //Move right
_right = true
_left = false
break;

case 2: //Move left
_left = true
_right = false
break;

case 3: //Move Up
_up = true
_down = false
break;

case 4: //Move Down
_down = true
_up = false
break;

case 5: //Stop right
_right = false
break;

case 6: //Stop Left
_left = false
break;

case 7: //Stop Up
_up = false
break;

case 8: //Stop Down 
_down = false
break;

}


Okay, this should be simple to understand...the switch at the beginning will get the value
that the player sends when he presses a key or releases it.
We then switch to the case and change the values....easy, huh?

Now at the bottom of the script we add the following:


clearbuffer()
writebyte(MSG_MOVE)
writeshort(playerid)
writebyte(_dir)
send_client(1)

This is the part that will inform the Clients what is happening.

The playerid must be sent so the client knows what player is moving.
The _dir is the key that was pressed/released.
And the send_client(1) means that we send the message to all Players in the same room =)
Ya, I must admit I've outdone myself with the "send_client(arg0)" script :P

Anyway...lets switch back to the client now =)

We'll do it as we did on the Server.
Open the "obj_controller" and its "User Defined 0"-Event.
Open the script and get rid of the following lines:

case MSG_NEW_CONTACT: //A Player sets a new contact point
case_msg_new_contact()
break;

Great, kill em!
Now add the following:

case MSG_MOVE: //A Player moves
case_msg_move()
break;

Now create a script called "case_msg_move"

We add the following lines now:

with get_player()
{
switch(readbyte())
{
case 1: //Moves right
hspeed = 1
break;

case 2: //Moves left
hspeed = -1
break;

case 3: //Moves Up
vspeed = -1
break;

case 4: //Moves Down
vspeed = 1
break;

case 5:
case 6: //Stop moving Right
hspeed = 0
break;

case 7:
case 8: //Stop moving up or down
vspeed = 0
break;
}

Yay, looks good and should explain itself.

Okay, save the server and the client and try it =)

It should work f you did all the stuff I wrote.

The only problem you might have is that after a warp you dont get teh info if a player is moving atm. 
But you can easily add that yourself..and its also good for practice :P

And, ya, I know that the blocks and such dont stop your player.
I am not here to make the whole engine for you :P

Have fun with this!

BlaXun